; ==========================================================
; Shared Constants
; ==========================================================
MaxWndData	equ	64
MaxWndNode	equ	64
StringLength	equ	32

MouseBtnLeft	equ	1h
MouseBtnRight	equ	2h

ProcessInterval	equ	1	; 1 tick

GraphScreenWidth	equ	320
GraphScreenHeight	equ	200

GameSimple		equ	0
GameNormal		equ	1

EvtNull			equ	0h
EvtMouseMove		equ	1h
EvtMouseLButtonDown	equ	2h
EvtMouseLButtonUp	equ	3h
EvtMouseRButtonDown	equ	4h
EvtMouseRButtonUp	equ	5h
EvtKeyPressed		equ	6h

CmdNull			equ	0h
CmdButton		equ	1h

ModalResultNull		equ	0
ModalResultOk		equ	1
ModalResultCancel	equ	2

StateNull		equ	0
StateMoving		equ	1
StateBtnHover		equ	11h
StateBtnDown		equ	12h

Spr1			equ	0
Spr2			equ	1
Spr3			equ	2
Spr4			equ	3
Spr5			equ	4
Spr6			equ	5
Spr7			equ	6
Spr8			equ	7
SprPressed		equ	8
SprMineWrong		equ	9
SprMine			equ	10
SprChecked		equ	11
SprClear		equ	12

SprBigTile		equ	0
SprSmallTile		equ	13

ColorBlack		equ	0
ColorDarkGray		equ	4
ColorGray		equ	6
ColorLightGray		equ	8
ColorWhite		equ	255

ColorRed		equ	220
ColorDarkRed		equ	33
ColorBlue		equ	45
ColorDarkBlue		equ	48

WndFlagNumbersOnly	equ	1
WndFlagFirstFocus	equ	2

WndTitleHeight		equ	20

ResourceBufferAddr	equ	08000h	; Resource Buffer Address
BackBufferAddr		equ	09000h	; Back Buffer Address


; ==========================================================
; Shared Typedefs
; ==========================================================
NearPtr		typedef	word
FuncPtr		typedef	word

; ==========================================================
; Shared Structures
; ==========================================================
TWndData	struct
	Valid		byte	0
	State		byte	0
	Parent		NearPtr	0
	Child		NearPtr	0
	Sibling		NearPtr	0
	WndClass	NearPtr	0
	X		word	?
	Y		word	?
	SizeX		word	?
	SizeY		word	?
	Flags		byte	0
	Color		byte	?
	Text		byte	StringLength dup (?)
TWndData	ends


TWndClass	struct
	OnInit		FuncPtr ?
	OnCleanup	FuncPtr ?
	OnDraw		FuncPtr	?
	OnProcess	FuncPtr	?
	OnKey		FuncPtr	?
	OnMouse		FuncPtr	?
	OnCommand	FuncPTr ?
TWndClass	ends


TEventData	struct
	EventType	word	0
	KeyChar		byte	0
	KeyCode		byte	0
	MouseX		word	0
	MouseY		word	0
	ButtonKind	word	0
	ButtonState	word	0
TEventData	ends


TCommandData	struct
	CommandType	word	0
	Sender		word	0
	Data		word	0
TCommandData	ends


TMouseData	struct
	MouseX		word	0
	MouseY		word	0
	ButtonState	word	0
TMouseData	ends


; ==========================================================
; Shared Variables and Procedures
; ==========================================================

externdef	NullString: byte

; ---- Base - Procedures
externdef	ExitProgram: near
externdef	GetClockTick: near
externdef	NumberToString: near
externdef	StringToNumber: near
externdef	StrCopy: near
externdef	StrCatChar: near
externdef	Beep: near

; ---- Random - Procedures
externdef	Randomize: near
externdef	GetRandom: near

; ---- UI - Variables
externdef	RootWnd: word
externdef	CurrStageWnd: word
externdef	ActiveWnd: word
externdef	ModalWnd: word
externdef	ModalResult: word
externdef	EventData: TEventData
externdef	CommandData: TCommandData
externdef	NextStageClass: NearPtr
externdef	Terminated: byte
externdef	MoveFocusTryCount: word

; ---- UI - Procedures
externdef	AllocWndData: near
externdef	AddChildWnd: near
externdef	DeleteChildWnd: near
externdef	UIDraw: near
externdef	UIProcess: near
externdef	UIKey: near
externdef	UIMouse: near
externdef	UICommand: near
externdef	DoNothing: near
externdef	DefWndOnMouse: near
externdef	DefWndOnKey: near
externdef	DefMovingWndOnMouse: near
externdef	DefMovingWndOnDraw: near
externdef	DrawMouseCursor: near
externdef	InitUI: near
externdef	MainLoopProcedure: near
externdef	IsCursorVisible: near
externdef	MoveFocus: near
externdef	ShowModal: near

; ---- Graphics - Variables
externdef	GraphOriginX: word
externdef	GraphOriginY: word
externdef	GraphClipLeft: word
externdef	GraphClipTop: word
externdef	GraphClipRight: word
externdef	GraphClipBottom: word
externdef	GraphOldOriginX: word
externdef	GraphOldOriginY: word
externdef	GraphOldClipLeft: word
externdef	GraphOldClipTop: word
externdef	GraphOldClipRight: word
externdef	GraphOldClipBottom: word

; ---- Graphics - Procedures
externdef	SetGraphicMode: near
externdef	LoadResource: near
externdef	DrawBorder: near
externdef	FillRect: near
externdef	Present: near
externdef	ClearScreen: near

externdef	DrawRect: near
externdef	LoadPCX: near
externdef	DrawPCX: near
externdef	DrawText: near
externdef	DrawSprite: near


; ---- Input - Procedures
externdef	IsMouseInstalled: near
externdef	ShowMouseCursor: near
externdef	HideMouseCursor: near
externdef	GetMouseState: near
externdef	SetMousePos: near
externdef	SetMouseHorzRange: near
externdef	SetMouseVertRange: near
externdef	IsKeyPressed: near
externdef	GetKey: near

; ---- Controls - Variables
externdef	ButtonClass: TWndClass
externdef	EditBoxClass: TWndClass
externdef	LabelClass: TWndClass

; ---- Stage & Dialogs - Variables
externdef	MenuStageClass: TWndClass
externdef	NewStageClass: TWndClass
externdef	GameStageClass: TWndClass
externdef	ConfirmDlgClass: TWndClass
externdef	DialogTitle: NearPtr
externdef	DialogLine1: NearPtr
externdef	DialogLine2: NearPtr
externdef	DialogLine3: NearPtr


; ---- Stage & Dialogs - Procedures
externdef	CreateDlgConfirm: near

; ---- GameStg - Variables
externdef	GameMode: byte
externdef	BoardSizeX: word
externdef	BoardSizeY: word
externdef	MineCount: word

